# Huawei Technologies Co.,Ltd.

set(MULTIARGS_JS ${CMAKE_CURRENT_SOURCE_DIR}/multiargs.js)
set(MULTIARGS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/multiargs.txt)
set(MULTIARGS_BIN ${CMAKE_CURRENT_BINARY_DIR}/multiargs.abc)
set(MULTIARGS_PA ${CMAKE_CURRENT_BINARY_DIR}/multiargs.pa)
set(MULTIARGS_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${PANDA_BINARY_ROOT}/pandastdlib/arkstdlib.abc --load-runtimes=\"ecmascript\" --compiler-enable-jit=false ${MULTIARGS_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${MULTIARGS_OUTPUT}
    COMMENT "running javascript multiargs testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${MULTIARGS_JS} --dump-assembly --output ${MULTIARGS_BIN} > ${MULTIARGS_PA}
    COMMAND rm -f ${MULTIARGS_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} > ${MULTIARGS_OUTPUT}
    COMMAND bash ${MULTIARGS_VERIFY} ${MULTIARGS_OUTPUT}
)
add_custom_target(multiargs
    DEPENDS ${MULTIARGS_OUTPUT} ${MULTIARGS_VERIFY}
)
add_dependencies(multiargs es2panda ark)
add_dependencies(ecmascript_common_tests multiargs)
